package cn.jlkj22.csmallproductteachers.ex.handler;

import cn.jlkj22.csmallproductteachers.ex.ServiceException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {


        @ExceptionHandler
        public String handleServiceException(ServiceException e) {
            return e.getMessage();
        }

        @ExceptionHandler
        public String handleNullPointerException(NullPointerException e) {
            return "程序出现了空指针异常，已经被处理！";
        }

        @ExceptionHandler
        public String handleRuntimeException(RuntimeException e) {
            return "程序出现了RuntimeException，已经被处理！";
        }
}
